package net.hmr_radio.hmrbot.meta;

//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2011-08-09 16:45:27")
/** */
public final class KeywordMeta extends org.slim3.datastore.ModelMeta<net.hmr_radio.hmrbot.model.Keyword> {

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<net.hmr_radio.hmrbot.model.Keyword, com.google.appengine.api.datastore.Key> key = new org.slim3.datastore.CoreAttributeMeta<net.hmr_radio.hmrbot.model.Keyword, com.google.appengine.api.datastore.Key>(this, "__key__", "key", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.StringAttributeMeta<net.hmr_radio.hmrbot.model.Keyword> keyword = new org.slim3.datastore.StringAttributeMeta<net.hmr_radio.hmrbot.model.Keyword>(this, "keyword", "keyword");

    /** */
    public final org.slim3.datastore.ModelRefAttributeMeta<net.hmr_radio.hmrbot.model.Keyword, org.slim3.datastore.ModelRef<net.hmr_radio.hmrbot.model.Message>, net.hmr_radio.hmrbot.model.Message> messageRef = new org.slim3.datastore.ModelRefAttributeMeta<net.hmr_radio.hmrbot.model.Keyword, org.slim3.datastore.ModelRef<net.hmr_radio.hmrbot.model.Message>, net.hmr_radio.hmrbot.model.Message>(this, "messageRef", "messageRef", org.slim3.datastore.ModelRef.class, net.hmr_radio.hmrbot.model.Message.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<net.hmr_radio.hmrbot.model.Keyword, java.lang.Long> version = new org.slim3.datastore.CoreAttributeMeta<net.hmr_radio.hmrbot.model.Keyword, java.lang.Long>(this, "version", "version", java.lang.Long.class);

    private static final KeywordMeta slim3_singleton = new KeywordMeta();

    /**
     * @return the singleton
     */
    public static KeywordMeta get() {
       return slim3_singleton;
    }

    /** */
    public KeywordMeta() {
        super("Keyword", net.hmr_radio.hmrbot.model.Keyword.class);
    }

    @Override
    public net.hmr_radio.hmrbot.model.Keyword entityToModel(com.google.appengine.api.datastore.Entity entity) {
        net.hmr_radio.hmrbot.model.Keyword model = new net.hmr_radio.hmrbot.model.Keyword();
        model.setKey(entity.getKey());
        model.setKeyword((java.lang.String) entity.getProperty("keyword"));
        if (model.getMessageRef() == null) {
            throw new NullPointerException("The property(messageRef) is null.");
        }
        model.getMessageRef().setKey((com.google.appengine.api.datastore.Key) entity.getProperty("messageRef"));
        model.setVersion((java.lang.Long) entity.getProperty("version"));
        return model;
    }

    @Override
    public com.google.appengine.api.datastore.Entity modelToEntity(java.lang.Object model) {
        net.hmr_radio.hmrbot.model.Keyword m = (net.hmr_radio.hmrbot.model.Keyword) model;
        com.google.appengine.api.datastore.Entity entity = null;
        if (m.getKey() != null) {
            entity = new com.google.appengine.api.datastore.Entity(m.getKey());
        } else {
            entity = new com.google.appengine.api.datastore.Entity(kind);
        }
        entity.setProperty("keyword", m.getKeyword());
        if (m.getMessageRef() == null) {
            throw new NullPointerException("The property(messageRef) must not be null.");
        }
        entity.setProperty("messageRef", m.getMessageRef().getKey());
        entity.setProperty("version", m.getVersion());
        entity.setProperty("slim3.schemaVersion", 1);
        return entity;
    }

    @Override
    protected com.google.appengine.api.datastore.Key getKey(Object model) {
        net.hmr_radio.hmrbot.model.Keyword m = (net.hmr_radio.hmrbot.model.Keyword) model;
        return m.getKey();
    }

    @Override
    protected void setKey(Object model, com.google.appengine.api.datastore.Key key) {
        validateKey(key);
        net.hmr_radio.hmrbot.model.Keyword m = (net.hmr_radio.hmrbot.model.Keyword) model;
        m.setKey(key);
    }

    @Override
    protected long getVersion(Object model) {
        net.hmr_radio.hmrbot.model.Keyword m = (net.hmr_radio.hmrbot.model.Keyword) model;
        return m.getVersion() != null ? m.getVersion().longValue() : 0L;
    }

    @Override
    protected void assignKeyToModelRefIfNecessary(com.google.appengine.api.datastore.AsyncDatastoreService ds, java.lang.Object model) {
        net.hmr_radio.hmrbot.model.Keyword m = (net.hmr_radio.hmrbot.model.Keyword) model;
        if (m.getMessageRef() == null) {
            throw new NullPointerException("The property(messageRef) must not be null.");
        }
        m.getMessageRef().assignKeyIfNecessary(ds);
    }

    @Override
    protected void incrementVersion(Object model) {
        net.hmr_radio.hmrbot.model.Keyword m = (net.hmr_radio.hmrbot.model.Keyword) model;
        long version = m.getVersion() != null ? m.getVersion().longValue() : 0L;
        m.setVersion(Long.valueOf(version + 1L));
    }

    @Override
    protected void prePut(Object model) {
    }

    @Override
    public String getSchemaVersionName() {
        return "slim3.schemaVersion";
    }

    @Override
    public String getClassHierarchyListName() {
        return "slim3.classHierarchyList";
    }

    @Override
    protected boolean isCipherProperty(String propertyName) {
        return false;
    }

    @Override
    protected void modelToJson(org.slim3.datastore.json.JsonWriter writer, java.lang.Object model, int maxDepth, int currentDepth) {
        net.hmr_radio.hmrbot.model.Keyword m = (net.hmr_radio.hmrbot.model.Keyword) model;
        writer.beginObject();
        org.slim3.datastore.json.Default encoder0 = new org.slim3.datastore.json.Default();
        if(m.getKey() != null){
            writer.setNextPropertyName("key");
            encoder0.encode(writer, m.getKey());
        }
        if(m.getKeyword() != null){
            writer.setNextPropertyName("keyword");
            encoder0.encode(writer, m.getKeyword());
        }
        if(m.getMessageRef() != null && m.getMessageRef().getKey() != null){
            writer.setNextPropertyName("messageRef");
            encoder0.encode(writer, m.getMessageRef(), maxDepth, currentDepth);
        }
        if(m.getVersion() != null){
            writer.setNextPropertyName("version");
            encoder0.encode(writer, m.getVersion());
        }
        writer.endObject();
    }

    @Override
    protected net.hmr_radio.hmrbot.model.Keyword jsonToModel(org.slim3.datastore.json.JsonRootReader rootReader, int maxDepth, int currentDepth) {
        net.hmr_radio.hmrbot.model.Keyword m = new net.hmr_radio.hmrbot.model.Keyword();
        org.slim3.datastore.json.JsonReader reader = null;
        org.slim3.datastore.json.Default decoder0 = new org.slim3.datastore.json.Default();
        reader = rootReader.newObjectReader("key");
        m.setKey(decoder0.decode(reader, m.getKey()));
        reader = rootReader.newObjectReader("keyword");
        m.setKeyword(decoder0.decode(reader, m.getKeyword()));
        reader = rootReader.newObjectReader("messageRef");
        decoder0.decode(reader, m.getMessageRef(), maxDepth, currentDepth);
        reader = rootReader.newObjectReader("version");
        m.setVersion(decoder0.decode(reader, m.getVersion()));
        return m;
    }
}